package com.sentinel.controller;

import com.cacos.pojo.User;
import com.feign.service.UserFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;


@RestController
public class ConsumerController {

    @Autowired
    private UserFeign userFeign;

//    @RequestMapping(value="/consumer/getUserById")
//    public User getUserById(Integer id){
//        return userFeign.getUserById(id);
//    }

    //线程数
    @RequestMapping(value="/consumer/getUserById")
    public User getUserById(Integer id) throws InterruptedException {
        Thread.sleep(500);
        System.out.println(Thread.currentThread().getName()+"------"+new Date());
        return userFeign.getUserById(id);
    }

    //每秒执行一次

    @RequestMapping(value="/test")
    public String test(){
        return "test";
    }
}
